package com.app.utils.jst.Data;

import com.app.utils.base.j2se.Convert;
import com.app.utils.base.j2se.StringHandler;

import java.util.ArrayList;
import java.util.Map;

public class GoodsList extends GoodsBase{

    public static GoodsList convert(Map<String, Object> data){
        GoodsList goodsList = new GoodsList();
        goodsList.id= Convert.objToStr(data.get("item_spu_id"));
        goodsList.name= Convert.objToStr(data.get("item_name"));
        long price1 = StringHandler.yuanToFen(Convert.objToStr(data.get("min_supply_price")));
        long price2 = StringHandler.yuanToFen(Convert.objToStr(data.get("min_sale_price")));
        if(price2-price1<500){
            price2 += price2-price1+500;
        }

        goodsList.price= StringHandler.fenToYuan(Convert.objToStr(price2));
        String pic = StringHandler.getString(data.get("main_image_list"));
        if(StringHandler.isNotEmpty(pic)){
            goodsList.cover_pic= Convert.objToStr(((ArrayList)data.get("main_image_list")).get(0));
        }else{
            goodsList.cover_pic= "";
        }
        return goodsList;
    }
}
